package validation;

import java.util.*;

import dbmanager.DBManager;

import utility.DateConversion;

public class Datedispatch implements Validation
{

	DateConversion mydt = new DateConversion();
	Calendar clndr = new GregorianCalendar();
	
	boolean FLAGE;
	
	public boolean validate(String Value){
		 //------------get current date in seperate variables -------------------
		 int currentday = clndr.get(Calendar.DAY_OF_MONTH);
		 int currentmonth = clndr.get(Calendar.MONTH)+1;
		 int currentyear = clndr.get(Calendar.YEAR);
		 
		 //------------ see the current date -------------------------------------
		 System.out.println("YEAR: " + currentyear);
		 System.out.println("MONTH: " + currentmonth);
		 System.out.println("DAY: " + currentday);
		 
		 //------------see in date format of your date -------------------------
		 System.out.print ("Date : "+mydt.getDate(Value,"YYYY-MM-DD"));
			 
		 //------------getting your date in seperate variables and print variables-----------------
		 int day = mydt.getDay(Value);
		 int month = mydt.getMonth(Value);
		 int year = mydt.getYear(Value);
		 
		 System.out.println ("Printing it serially !");
		 System.out.println ("Date = "+day+", Month = "+month+", Year = "+year);
		 		 
		 //---------------- now ONLY compare variables of your date and current date -----------------------------------------		 
		
		 if (year<currentyear)
		 {
			 return true;
		 }
		 else if (year==currentyear)
		{
			if (month<currentmonth)
			{
				return true;
			}
			else if (month==currentmonth)
			{
				if (day<=currentday)
				{
					
					return true;
				}
				else if (day>currentday)
				{
					return false;
				}
			}
		 }
	return false;
	}	
	
	public static void main(String[] args) {
		
		Datedispatch dd = new Datedispatch();
		
	    boolean chkdt = dd.validate("30042007");
		
		System.out.println(chkdt);		
	}

	public boolean validate(String Value, String conditionValue) {
		// TODO Auto-generated method stub
		return false;
	}

	public String getMessage() {
		// TODO Auto-generated method stub
		return "The delivery date must not be greter than current date.";
	}

	public void setDbmanager(DBManager database) {
		// TODO Auto-generated method stub
		
	}

	public boolean validate(String Value, String ConditionValue, String Refvalue) {
		// TODO Auto-generated method stub
		return false;
	}

	public void setBasicvalue(String value) 
	{
	
		
	}
}
